/**
 * Created with IntelliJ IDEA.
 * User: jiang.li
 * Date: 13-10-24
 * Time: 上午10:53
 * To change this template use File | Settings | File Templates.
 */

window.AllDocCrt = function ($rootScope, $scope) {

    //获取设备ID
    var _ctrl_device_id = top.CurrentDeviceApps;
    //查询参数组装
    $scope.queryParams || ( $scope.queryParams = {});
    $scope.queryParams.pageSize = 500;
    $scope.queryParams.deviceId = _ctrl_device_id;


    //加载数据函数
    var loadData = function () {
        $.ajax({
            url: '/services/api/common/device/queryApp',
            type: "GET",
            data: $scope.queryParams,
            dataType: "json",
            success: function (data) {
                $scope.pageData = pageToObj(data);
                $.each($scope.pageData.items, function (i, item) {
                    item.appSize_show = item.appSize ? (item.appSize / 1024 / 1024).toFixed(2) + " MB" : "未知";
                    item.icon_show = item.icon && item.icon != '' ? (_config.url_file + '/show/' + item.icon) : '';
                    item.appCreate_show = item.appCreate ? new Date(item.appCreate).showYFullTime(): "未知";
                });
                $scope.NORESULT = '没有查询到数据';
                applyAngularScope($rootScope, $scope);
            }
        });
    }

    //分页查询
    $scope.goPage = function (pageNo, className) {
        if (className == 'disabled') { return; }
        $scope.queryParams.pageNo = pageNo;
        loadData();
    }

    //首次加载数据
    loadData();
}